package org.txazo.blog.util;

import java.util.Map;

import org.txazo.blog.commons.prop.ClassPathProperties;
import org.txazo.blog.commons.prop.Properties;

/**
 * Context工具类
 * 
 * @author Tu XiaoZhou
 * @since 2013-08-10
 * 
 */
public class ContextUtil {

	private static String baseHref = null;
	private static String domainName = null;
	private static String webPath = null;
	private static String webClassPath = null;
	private static String jsPath = null;
	private static String cssPath = null;
	private static String imagePath = null;
	private static String blog1Path = null;
	private static String blog2Path = null;
	private static String blog3Path = null;

	static {
		init();
	}

	private static void init() {
		webPath = System.getProperty("web.path");

		Properties properties = new ClassPathProperties("context.properties");
		Map<String, String> map = properties.load();

		baseHref = map.get("baseHref");
		domainName = baseHref.substring(7, baseHref.length());
		webClassPath = webPath + "/WEB-INF/classes";
		jsPath = webPath + map.get("jsPath");
		cssPath = webPath + map.get("cssPath");
		imagePath = webPath + map.get("imagePath");
		blog1Path = webPath + map.get("blog1Path");
		blog2Path = webPath + map.get("blog2Path");
		blog3Path = webPath + map.get("blog3Path");

		System.out.println(baseHref);
		System.out.println(domainName);
		System.out.println(webPath);
		System.out.println(webClassPath);
		System.out.println(jsPath);
		System.out.println(cssPath);
		System.out.println(imagePath);
		System.out.println(blog1Path);
		System.out.println(blog2Path);
		System.out.println(blog3Path);
	}

	/** Base Href */
	public static String getBaseHref() {
		return baseHref;
	}

	/** Domain Name */
	public static String getDomainName() {
		return domainName;
	}

	/** Web项目根路径 */
	public static String getWebPath() {
		return webPath;
	}

	/** Web项目类路径 */
	public static String getWebClassPath() {
		return webClassPath;
	}

	/** Web项目JS路径 */
	public static String getJSPath() {
		return jsPath;
	}

	/** Web项目Css路径 */
	public static String getCssPath() {
		return cssPath;
	}

	/** Web项目图片路径 */
	public static String getImagePath() {
		return imagePath;
	}

	public static String getBlog1Path() {
		return blog1Path;
	}

	public static String getBlog2Path() {
		return blog2Path;
	}

	public static String getBlog3Path() {
		return blog3Path;
	}

}
